package com.report.reportserver.controller;

import com.report.reportserver.model.Legend;
import com.report.reportserver.service.LegendService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;
import java.util.ArrayList;
import java.util.List;

/**
 * @ ClassName: LegendController
 * @ Description：返回Legend对象
 * @ Modified By：
 * @ Version:
 * @ Author     ：LiYing
 * @ Date       ：Created in 17:14 2022/2/28
 */
@Controller
public class LegendController {

    @Autowired
    LegendService legendService;

    @RequestMapping(value = "/legend")
    public @ResponseBody Legend legend(String id){
        int ids = Integer.parseInt(id);
        Legend legend = legendService.queryLegendById(ids);
        return legend;
    }

    @RequestMapping(value = "/legend/all")
    public @ResponseBody
    List<Object> legend_all(){
        List<Object> list = new ArrayList<>();
        for(int i = 1;i <= 159;i++ ){
            list.add(legendService.queryLegendById(i));
        }
        return list;
    }
}
